package com.pactera.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.http.HttpServletRequest;

public class PropConfigUtil {

	private static final String CONFINGPATH="/third-config.properties";
	
	public static String getValueByKey(String key){
		Properties prop =  new  Properties();    
		InputStream in = PropConfigUtil.class.getResourceAsStream(CONFINGPATH);  
		String value="";
		try{    
			prop.load(in);    
			value = prop.getProperty(key).trim(); 
		  }catch(Exception e) {    
		      e.printStackTrace();
		 }
		return value;
	}
	
	public static String getSSOValueByKey(String key, HttpServletRequest request) {
		Properties prop =  new  Properties();    
		InputStream in = request.getServletContext().getResourceAsStream("/WEB-INF/sso-config.properties");
		String value="";
		try {
			prop.load(in);
			value = prop.getProperty(key).trim();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return value;
	}
}
